package com.zx.core.enums;


import lombok.Getter;

/**
 * <p>
 * description: 性别枚举定义 <br>
 * create: 2024-10-14 13:53
 * </p>
 *
 * @author zhou  xun
 */

@Getter
public enum GenderEnum {
    /**
     * 1-男
     */
    MALE("男", 1),
    /**
     * 2-女
     */
    FEMALE("女", 2),
    /**
     * 0-未说明性别
     */
    UNKNOWN("未说明性别", 0);
    /**
     * 性别名称
     */
    private final String genderName;
    /**
     * 性别值
     */
    private final Integer genderValue;

    GenderEnum(String genderName, Integer genderValue) {
        this.genderName = genderName;
        this.genderValue = genderValue;
    }

    public static GenderEnum getGenderBySexName(String name) {
        for (GenderEnum value : values()) {
            if (value.genderName.equals(name)) {
                return value;
            }
        }
        return null;
    }

    public static GenderEnum getGenderBySexValue(Integer sexValue) {
        for (GenderEnum value : values()) {
            if (value.genderValue.equals(sexValue)) {
                return value;
            }
        }
        return null;
    }


}
